"""
Edit file hatwidget.kv for editing the background or other parameters of UI.

To use it, you should import this file (add 'from hat_widget import HatWidget'
to your program).
Your root widget should inherit HatWidget.

ATTENTION: .kv file for screen should NOT contain it's own color of background.
"""

from kivy.uix.boxlayout import BoxLayout

from kivy.properties import NumericProperty
from kivy.properties import StringProperty
from kivy.uix.popup import Popup
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label


class HatWidget(BoxLayout):
    def __init__(self, **kwargs):
        super(HatWidget, self).__init__(**kwargs)

    def go_back(self):
        pass

    def open_ok_popup(self, title, text):
        button_ok = Button(text=u'OK', size_hint_y=None,
                           height=self.height / 9)
        content = BoxLayout(orientation='vertical')
        content.add_widget(Label(text=text))
        content.add_widget(button_ok)
        popup = Popup(content=content,
                      title=title,
                      size_hint=(None, None),
                      size=(self.width / 2, self.height / 3))
        button_ok.bind(on_release=popup.dismiss)
        popup.open()
